package com.example.lottery.service.enums;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;


//@NoArgsConstructor
//@AllArgsConstructor
public enum UserIdentityEnum {
    NORMAL("普通用户"),
    ADMIN("管理员");
    private final String message;

    UserIdentityEnum(String message) {
        this.message = message;
    }

    public String getMessage() {
        return message;
    }
    public static UserIdentityEnum forName(String name){
        if(name==null||name.trim().isEmpty()){
            return null;
        }
        //UserIdentityEnum.values() 会返回枚举类的数组[NORMAL,ADMIN]
        for(UserIdentityEnum userIdentityEnum:UserIdentityEnum.values()){
            //userIdentityEnum.name()这里的name是方法，相当于是调用枚举类的名称
            if(userIdentityEnum.name().equalsIgnoreCase(name)){
                return userIdentityEnum;
            }
        }
        return null;
    }

//    public static void main(String[] args) {
//
//
//            UserIdentityEnum userIdentityEnum = UserIdentityEnum.forName("ADMIN");
//            System.out.println(userIdentityEnum.getMessage());
//
//    }
}
